// https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs
// nuxt.config.js
// const basePath = '基础路径' // 默认为 '/'
const basePath = '/main' // 默认为 '/'
// 静态资源路径前缀
const assetPrefix =
  process.env.NODE_ENV === 'production'
    ? `线上域名${basePath}`
    : `http://localhost:${process.env.PORT || 3000}${basePath}`

module.exports = {
  // 将 assetPrefix 写入环境变量，通过 process.env.assetPrefix 访问
  env: {
    assetPrefix,
  },
  // 设置基础路径
  router: {
    base: basePath,
  },
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'child-nuxt2-home',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['element-ui/lib/theme-chalk/index.css', '@/assets/style/main.scss'],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: ['@/plugins/element-ui'],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/proxy',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    baseURL: '/',
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: [/^element-ui/],
  },
  proxy: {
    '/api': {
      // target: 'http://jsonplaceholder.typicode.com',
      target: 'http://hrotest.huokesaas.com',
      changeOrigin: true,
      // rewrite: (path) => path.replace(/^\/api/, ''),
    },
  },
  telemetry: false,
}
